
// 不能这么写，时间后面都不更新
// var now = new Date();

const nowDate = () => {
	var now = new Date();
	let year = now.getFullYear();
	let month = String(now.getMonth() + 1).padStart(2, '0');
	let day = String(now.getDate()).padStart(2, '0');
	
	let nowDate = year + '-' + month + '-' + day;
	return nowDate;
}

const endDate = (dateNum) => {
	var now = new Date();
	let now1 = new Date(now);
	now1.setDate(now.getDate() + parseFloat(dateNum));
	
	let year = now1.getFullYear();
	let month = String(now1.getMonth() + 1).padStart(2, '0');
	let day = String(now1.getDate()).padStart(2, '0');
	
	let endDate = year + '-' + month + '-' + day;
	return endDate;
}

const timestaDate = (timestamp) => {
	let date = new Date(timestamp)
	let year = date.getFullYear();
	let month = String(date.getMonth() + 1).padStart(2, '0');
	let day = String(date.getDate()).padStart(2, '0');
	
	let timestaDate = year + '-' + month + '-' + day;
	return timestaDate;
}

export default{
	nowDate,
	endDate,
	timestaDate
}